package org.cloud.common.config;

import javax.annotation.PostConstruct;

import org.cloud.common.util.EmailUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import lombok.Getter;
import lombok.Setter;

/**
 * 邮件配置
 * 
 * @author wangyuan
 * @since 2018年9月18日
 */
@Configuration
@ConfigurationProperties(prefix = "sloth.email")
@Setter
@Getter
public class EmailConfig {

    private String hostname;
    private Integer port;
    private String username;
    private String password;
    private Boolean auth;
    private String protocol;
    
    @PostConstruct
    public void init(){
        EmailUtils.setHost(hostname);
        EmailUtils.setPort(port);
        EmailUtils.setUsername(username);
        EmailUtils.setPassword(password);
        EmailUtils.setAuth(auth ? "true" : "false");
        EmailUtils.setProtocol(protocol);
    }
}
